package cn.kgc.vue.controller;

import cn.kgc.vue.commons.QueryCondition;
import cn.kgc.vue.commons.ResponseResult;
import cn.kgc.vue.entity.LogInfo;
import cn.kgc.vue.service.LogInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date 2024/7/11
 * @description
 */
@RestController
@RequestMapping("logs")
@Api(tags = "日志模块")
public class LogInfoController {

    @Resource
    private LogInfoService logInfoService;

    @ApiOperation("日志分页")
    @PostMapping("page")
    public ResponseResult logsPage(@RequestBody QueryCondition<LogInfo> queryCondition) {

        return logInfoService.logsPage(queryCondition);

    }


    @ApiOperation("批量删除")
    @DeleteMapping("delete")
    public ResponseResult deleteLogs(@RequestBody List<Integer> ids) {

        logInfoService.removeBatchByIds(ids);
        return ResponseResult.success().message("删除成功");

    }

    @ApiOperation("导出日志")
    @PostMapping("export")
    public void exportLogs(@RequestBody Map<String,String> params, HttpServletResponse response) {


        logInfoService.exportLogs(params,response);

    }
}
